home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / wb-enhancement / blanker / vesa / blank.c next >
C/C++ Source or Header  |  1996-02-26  |  4KB  |  125 lines

  1. /*
  2.  *  Copyright (c) 1996 Mika Kortelainen
  3.  *  All rights reserved.
  4.  *
  5.  */
  6.  
  7. #include <exec/memory.h>
  8. #include <cybergraphics/cybergraphics.h>
  9. #include "/includes.h"
  10.  
  11. #ifdef __SASC_60
  12. #  include <proto/cybergraphics.h>
  13. #else
  14. #  include <clib/cybergraphics_protos.h>
  15. #  ifndef _DCC
  16. #    include <inline/cybergraphics.h>
  17. #  endif
  18. #endif
  19.  
  20. #define NORMAL  0
  21. #define STANDBY 1
  22. #define SUSPEND 2
  23.  
  24.  
  25. #define CYBERGFXNAME     "cybergraphics.library"
  26. #define CYBERGFXVERSION  40L
  27.  
  28. #ifdef __SASC_650
  29. /* use SAS/C 6.5x's autoinit feature */
  30. LONG __CGFXlibversion = CYBERGFXVERSION;
  31. #else
  32. struct Library *CyberGfxBase;
  33. #endif
  34.  
  35. #include "Vesa_rev.h"
  36. STATIC const UBYTE VersTag[] = VERSTAG;
  37.  
  38.  
  39. VOID Defaults( PrefObject *Prefs )
  40. {
  41.         Prefs[NORMAL].po_Level = 1;
  42.         Prefs[STANDBY].po_Level = 1;
  43.         Prefs[SUSPEND].po_Level = 1;
  44. }
  45.  
  46.  
  47. LONG Blank( PrefObject *Prefs )
  48. {
  49.         struct Screen *FScr;
  50.         LONG RetVal;
  51.  
  52. #ifndef __SASC_650
  53.         if ((CyberGfxBase=OpenLibrary(CYBERGFXNAME,CYBERGFXVERSION))==NULL)
  54.         {
  55.                 return FAILED;
  56.         }
  57. #endif
  58.  
  59.         if( (FScr = cloneTopScreen(FALSE, TRUE)) )
  60.         {
  61.                 LONG count = 0;
  62.                 LONG normalMode = Prefs[NORMAL].po_Level * 60;
  63.                 LONG standbyMode = normalMode + Prefs[STANDBY].po_Level * 60;
  64.                 LONG suspendMode = standbyMode + Prefs[SUSPEND].po_Level * 60;
  65.                 struct Window *Wnd;
  66.  
  67.                 SetRGB4( &FScr->ViewPort, 0, 0L, 0L, 0L );
  68.                 SetRast( &FScr->RastPort, 0 );
  69.                 Wnd = BlankMousePointer( FScr );
  70.                 ScreenToFront( FScr );
  71.  
  72.                 do
  73.                 {
  74.                         Delay(50);
  75.  
  76.                         if (count == normalMode)
  77.                         {
  78.                                 CVideoCtrlTags(&FScr->ViewPort,
  79.                                                SETVC_DPMSLevel,
  80.                                                DPMS_STANDBY,
  81.                                                TAG_DONE);
  82.                                 count++;
  83.                         } else if (count == standbyMode)
  84.                         {
  85.                                 CVideoCtrlTags(&FScr->ViewPort,
  86.                                                SETVC_DPMSLevel,
  87.                                                DPMS_SUSPEND,
  88.                                                TAG_DONE);
  89.                                 count++;
  90.                         } else if (count == suspendMode)
  91.                         {
  92.                                 CVideoCtrlTags(&FScr->ViewPort,
  93.                                                SETVC_DPMSLevel,
  94.                                                DPMS_OFF,
  95.                                                TAG_DONE);
  96.                                 count++;
  97.                         } else if (count < suspendMode)
  98.                         {
  99.                                 count++;
  100.                         }
  101.  
  102.                         RetVal = ContinueBlanking();
  103.                 }
  104.                 while( RetVal == OK );
  105.  
  106.                 CVideoCtrlTags(&FScr->ViewPort,
  107.                                SETVC_DPMSLevel,
  108.                                DPMS_ON,
  109.                                TAG_DONE);
  110.                 UnblankMousePointer( Wnd );
  111.                 CloseScreen( FScr );
  112.                 (void)RethinkDisplay();
  113.         } else {
  114.                 /* Couldn't open screen */
  115.                 RetVal = FAILED;
  116.         }
  117.  
  118. #ifndef __SASC_650
  119.         CloseLibrary(CyberGfxBase);
  120. #endif
  121.  
  122.         return RetVal;
  123. }
  124.  
  125.